package us.mooresr.aircraftscheduling.client.events;

import us.mooresr.aircraftscheduling.shared.model.User;
import us.mooresr.aircraftscheduling.shared.model.UserDetail;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HasHandlers;

public class UserLoggedInEvent extends
		GwtEvent<UserLoggedInEventHandler> {

	public static Type<UserLoggedInEventHandler> TYPE = new Type<UserLoggedInEventHandler>();
	
	private final UserDetail userDetail;


	public UserLoggedInEvent(UserDetail userDetail) {
		this.userDetail = userDetail;
	}

	@Override
	protected void dispatch(UserLoggedInEventHandler handler) {
		handler.onLogin(this);
	}

	@Override
	public Type<UserLoggedInEventHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<UserLoggedInEventHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, UserDetail userDetail) {
		source.fireEvent(new UserLoggedInEvent(userDetail));
	}

	public UserDetail getUserDetail() {
		return userDetail;
	}
	
	
}
